package com.situ.company.web220111.score.service.impl;

import com.situ.company.web220111.score.dao.IScoreDao;
import com.situ.company.web220111.score.dao.impl.ScoreDaoImpl;
import com.situ.company.web220111.score.model.ScoreModel;
import com.situ.company.web220111.score.service.IScoreService;

import java.util.List;

public class ScoreServiceImpl implements IScoreService {

    IScoreDao dao = new ScoreDaoImpl();

    @Override
    public String insert(ScoreModel model) {
        ScoreModel m1 = new ScoreModel();
        m1.setCodeEmp(model.getCodeEmp());
        m1.setCodePro(model.getCodePro());
        ScoreModel mdb = dao.selectModel(m1);
        if (mdb != null) {
            return "repeat";
        }
        return dao.insert(model) + "";
    }

    @Override
    public String delete(ScoreModel model) {
        return dao.delete(model) + "";
    }

    @Override
    public List<ScoreModel> selectList(ScoreModel model) {
        return dao.selectList(model);
    }

    @Override
    public ScoreModel selectModel(ScoreModel model) {
        return dao.selectModel(model);
    }

    @Override
    public Integer selectCount(ScoreModel model) {
        ScoreModel m1 = new ScoreModel();
        String codeemp = model.getCodeEmp();
        m1.setCodeEmp(codeemp == null ? "%" : "%" + codeemp + "%");
        String codepro = model.getCodePro();
        m1.setCodePro(codepro == null ? "%" : "%" + codepro + "%");
        return dao.selectCount(m1);
    }

    @Override
    public String updateActive(ScoreModel model) {
        return dao.updateActive(model);
    }

}
